<%--
  Created by IntelliJ IDEA.
  User: lxw
  Date: 2017/8/17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>成功</title>
</head>
<body>
<h3 style="text-align:center">权限查看</h3>
<table id="showList" border="1"></table>
<input type="button" value="退出登陆" onclick="loginout()"/>
<script type="text/javascript" src="<%=basePath%>static/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
//    登出跳转
    function loginout() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "rest/user/logout",
            success: function (data) {
                window.location.href = "rest/user/toLogin";
            }
        });
    }

//        显示权限
    function show() {
        $.ajax({
            type: "GET",
            url: "rest/user/list",
            dataType: "json",
            success: function (data) {
                var list = data.data;
                console.log(list);
                var ListHtml = "<tr><th>用户</th><th>角色</th><th>权限</th></tr>";
                $.each(list, function (i,n) {
                    ListHtml = ListHtml + "<tr><td>" + n.username + "&nbsp;&nbsp;</td><td>" + n.rname + "&nbsp;&nbsp;</td><td>" + n.url + "</td></tr>";
                });
                $("#showList").html(ListHtml);
            }
        });
    }
    show();
</script>
</body>
</html>